<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- Copyright (C) 1988-2017 Free Software Foundation, Inc.

Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
any later version published by the Free Software Foundation; with the
Invariant Sections being "Free Software" and "Free Software Needs
Free Documentation", with the Front-Cover Texts being "A GNU Manual,"
and with the Back-Cover Texts as in (a) below.

(a) The FSF's Back-Cover Text is: "You are free to copy and modify
this GNU Manual.  Buying copies from GNU Press supports the FSF in
developing GNU and promoting software freedom." -->
<!-- Created by GNU Texinfo 5.2, http://www.gnu.org/software/texinfo/ -->
<head>
<title>Debugging with GDB: Auto-loading</title>

<meta name="description" content="Debugging with GDB: Auto-loading">
<meta name="keywords" content="Debugging with GDB: Auto-loading">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="index.html#Top" rel="start" title="Top">
<link href="Concept-Index.html#Concept-Index" rel="index" title="Concept Index">
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
<link href="Controlling-GDB.html#Controlling-GDB" rel="up" title="Controlling GDB">
<link href="Init-File-in-the-Current-Directory.html#Init-File-in-the-Current-Directory" rel="next" title="Init File in the Current Directory">
<link href="ABI.html#ABI" rel="prev" title="ABI">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
blockquote.smallquotation {font-size: smaller}
div.display {margin-left: 3.2em}
div.example {margin-left: 3.2em}
div.indentedblock {margin-left: 3.2em}
div.lisp {margin-left: 3.2em}
div.smalldisplay {margin-left: 3.2em}
div.smallexample {margin-left: 3.2em}
div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
div.smalllisp {margin-left: 3.2em}
kbd {font-style:oblique}
pre.display {font-family: inherit}
pre.format {font-family: inherit}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
pre.smalldisplay {font-family: inherit; font-size: smaller}
pre.smallexample {font-size: smaller}
pre.smallformat {font-family: inherit; font-size: smaller}
pre.smalllisp {font-size: smaller}
span.nocodebreak {white-space:nowrap}
span.nolinebreak {white-space:nowrap}
span.roman {font-family:serif; font-weight:normal}
span.sansserif {font-family:sans-serif; font-weight:normal}
ul.no-bullet {list-style: none}
-->
</style>


</head>

<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
<a name="Auto_002dloading"></a>
<div class="header">
<p>
Next: <a href="Messages_002fWarnings.html#Messages_002fWarnings" accesskey="n" rel="next">Messages/Warnings</a>, Previous: <a href="ABI.html#ABI" accesskey="p" rel="prev">ABI</a>, Up: <a href="Controlling-GDB.html#Controlling-GDB" accesskey="u" rel="up">Controlling GDB</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html#Concept-Index" title="Index" rel="index">Index</a>]</p>
</div>
<hr>
<a name="Automatically-loading-associated-files"></a>
<h3 class="section">22.7 Automatically loading associated files</h3>
<a name="index-auto_002dloading"></a>

<p><small>GDB</small> sometimes reads files with commands and settings automatically,
without being explicitly told so by the user.  We call this feature
<em>auto-loading</em>.  While auto-loading is useful for automatically adapting
<small>GDB</small> to the needs of your project, it can sometimes produce unexpected
results or introduce security risks (e.g., if the file comes from untrusted
sources).
</p>
<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top">&bull; <a href="Init-File-in-the-Current-Directory.html#Init-File-in-the-Current-Directory" accesskey="1">Init File in the Current Directory</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">&lsquo;<samp>set/show/info auto-load local-gdbinit</samp>&rsquo;
</td></tr>
<tr><td align="left" valign="top">&bull; <a href="libthread_005fdb_002eso_002e1-file.html#libthread_005fdb_002eso_002e1-file" accesskey="2">libthread_db.so.1 file</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">&lsquo;<samp>set/show/info auto-load libthread-db</samp>&rsquo;
</td></tr>
<tr><th colspan="3" align="left" valign="top"><pre class="menu-comment">
</pre></th></tr><tr><td align="left" valign="top">&bull; <a href="Auto_002dloading-safe-path.html#Auto_002dloading-safe-path" accesskey="3">Auto-loading safe path</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">&lsquo;<samp>set/show/info auto-load safe-path</samp>&rsquo;
</td></tr>
<tr><td align="left" valign="top">&bull; <a href="Auto_002dloading-verbose-mode.html#Auto_002dloading-verbose-mode" accesskey="4">Auto-loading verbose mode</a>:</td><td>&nbsp;&nbsp;</td><td align="left" valign="top">&lsquo;<samp>set/show debug auto-load</samp>&rsquo;
</td></tr>
</table>

<p>There are various kinds of files <small>GDB</small> can automatically load.
In addition to these files, <small>GDB</small> supports auto-loading code written
in various extension languages.  See <a href="Auto_002dloading-extensions.html#Auto_002dloading-extensions">Auto-loading extensions</a>.
</p>
<p>Note that loading of these associated files (including the local <samp>.gdbinit</samp>
file) requires accordingly configured <code>auto-load safe-path</code>
(see <a href="Auto_002dloading-safe-path.html#Auto_002dloading-safe-path">Auto-loading safe path</a>).
</p>
<p>For these reasons, <small>GDB</small> includes commands and options to let you
control when to auto-load files and which files should be auto-loaded.
</p>
<dl compact="compact">
<dd><a name="set-auto_002dload-off"></a><a name="index-set-auto_002dload-off"></a>
</dd>
<dt><code>set auto-load off</code></dt>
<dd><p>Globally disable loading of all auto-loaded files.
You may want to use this command with the &lsquo;<samp>-iex</samp>&rsquo; option
(see <a href="Startup.html#Option-_002dinit_002deval_002dcommand">Option -init-eval-command</a>) such as:
</p><div class="smallexample">
<pre class="smallexample">$ <kbd>gdb -iex &quot;set auto-load off&quot; untrusted-executable corefile</kbd>
</pre></div>

<p>Be aware that system init file (see <a href="System_002dwide-configuration.html#System_002dwide-configuration">System-wide configuration</a>)
and init files from your home directory (see <a href="Startup.html#Home-Directory-Init-File">Home Directory Init File</a>)
still get read (as they come from generally trusted directories).
To prevent <small>GDB</small> from auto-loading even those init files, use the
<samp>-nx</samp> option (see <a href="Mode-Options.html#Mode-Options">Mode Options</a>), in addition to
<code>set auto-load no</code>.
</p>
<a name="show-auto_002dload"></a><a name="index-show-auto_002dload"></a>
</dd>
<dt><code>show auto-load</code></dt>
<dd><p>Show whether auto-loading of each specific &lsquo;<samp>auto-load</samp>&rsquo; file(s) is enabled
or disabled.
</p>
<div class="smallexample">
<pre class="smallexample">(gdb) show auto-load
gdb-scripts:  Auto-loading of canned sequences of commands scripts is on.
libthread-db:  Auto-loading of inferior specific libthread_db is on.
local-gdbinit:  Auto-loading of .gdbinit script from current directory
                is on.
python-scripts:  Auto-loading of Python scripts is on.
safe-path:  List of directories from which it is safe to auto-load files
            is $debugdir:$datadir/auto-load.
scripts-directory:  List of directories from which to load auto-loaded scripts
                    is $debugdir:$datadir/auto-load.
</pre></div>

<a name="info-auto_002dload"></a><a name="index-info-auto_002dload"></a>
</dd>
<dt><code>info auto-load</code></dt>
<dd><p>Print whether each specific &lsquo;<samp>auto-load</samp>&rsquo; file(s) have been auto-loaded or
not.
</p>
<div class="smallexample">
<pre class="smallexample">(gdb) info auto-load
gdb-scripts:
Loaded  Script
Yes     /home/user/gdb/gdb-gdb.gdb
libthread-db:  No auto-loaded libthread-db.
local-gdbinit:  Local .gdbinit file &quot;/home/user/gdb/.gdbinit&quot; has been
                loaded.
python-scripts:
Loaded  Script
Yes     /home/user/gdb/gdb-gdb.py
</pre></div>
</dd>
</dl>

<p>These are <small>GDB</small> control commands for the auto-loading:
</p>
<table>
<tr><td width="50%">See <a href="#set-auto_002dload-off">set auto-load off</a>.</td><td width="50%">Disable auto-loading globally.</td></tr>
<tr><td width="50%">See <a href="#show-auto_002dload">show auto-load</a>.</td><td width="50%">Show setting of all kinds of files.</td></tr>
<tr><td width="50%">See <a href="#info-auto_002dload">info auto-load</a>.</td><td width="50%">Show state of all kinds of files.</td></tr>
<tr><td width="50%">See <a href="Auto_002dloading-sequences.html#set-auto_002dload-gdb_002dscripts">set auto-load gdb-scripts</a>.</td><td width="50%">Control for <small>GDB</small> command scripts.</td></tr>
<tr><td width="50%">See <a href="Auto_002dloading-sequences.html#show-auto_002dload-gdb_002dscripts">show auto-load gdb-scripts</a>.</td><td width="50%">Show setting of <small>GDB</small> command scripts.</td></tr>
<tr><td width="50%">See <a href="Auto_002dloading-sequences.html#info-auto_002dload-gdb_002dscripts">info auto-load gdb-scripts</a>.</td><td width="50%">Show state of <small>GDB</small> command scripts.</td></tr>
<tr><td width="50%">See <a href="Python-Auto_002dloading.html#set-auto_002dload-python_002dscripts">set auto-load python-scripts</a>.</td><td width="50%">Control for <small>GDB</small> Python scripts.</td></tr>
<tr><td width="50%">See <a href="Python-Auto_002dloading.html#show-auto_002dload-python_002dscripts">show auto-load python-scripts</a>.</td><td width="50%">Show setting of <small>GDB</small> Python scripts.</td></tr>
<tr><td width="50%">See <a href="Python-Auto_002dloading.html#info-auto_002dload-python_002dscripts">info auto-load python-scripts</a>.</td><td width="50%">Show state of <small>GDB</small> Python scripts.</td></tr>
<tr><td width="50%">See <a href="Guile-Auto_002dloading.html#set-auto_002dload-guile_002dscripts">set auto-load guile-scripts</a>.</td><td width="50%">Control for <small>GDB</small> Guile scripts.</td></tr>
<tr><td width="50%">See <a href="Guile-Auto_002dloading.html#show-auto_002dload-guile_002dscripts">show auto-load guile-scripts</a>.</td><td width="50%">Show setting of <small>GDB</small> Guile scripts.</td></tr>
<tr><td width="50%">See <a href="Guile-Auto_002dloading.html#info-auto_002dload-guile_002dscripts">info auto-load guile-scripts</a>.</td><td width="50%">Show state of <small>GDB</small> Guile scripts.</td></tr>
<tr><td width="50%">See <a href="objfile_002dgdbdotext-file.html#set-auto_002dload-scripts_002ddirectory">set auto-load scripts-directory</a>.</td><td width="50%">Control for <small>GDB</small> auto-loaded scripts location.</td></tr>
<tr><td width="50%">See <a href="objfile_002dgdbdotext-file.html#show-auto_002dload-scripts_002ddirectory">show auto-load scripts-directory</a>.</td><td width="50%">Show <small>GDB</small> auto-loaded scripts location.</td></tr>
<tr><td width="50%">See <a href="objfile_002dgdbdotext-file.html#add_002dauto_002dload_002dscripts_002ddirectory">add-auto-load-scripts-directory</a>.</td><td width="50%">Add directory for auto-loaded scripts location list.</td></tr>
<tr><td width="50%">See <a href="Init-File-in-the-Current-Directory.html#set-auto_002dload-local_002dgdbinit">set auto-load local-gdbinit</a>.</td><td width="50%">Control for init file in the current directory.</td></tr>
<tr><td width="50%">See <a href="Init-File-in-the-Current-Directory.html#show-auto_002dload-local_002dgdbinit">show auto-load local-gdbinit</a>.</td><td width="50%">Show setting of init file in the current directory.</td></tr>
<tr><td width="50%">See <a href="Init-File-in-the-Current-Directory.html#info-auto_002dload-local_002dgdbinit">info auto-load local-gdbinit</a>.</td><td width="50%">Show state of init file in the current directory.</td></tr>
<tr><td width="50%">See <a href="libthread_005fdb_002eso_002e1-file.html#set-auto_002dload-libthread_002ddb">set auto-load libthread-db</a>.</td><td width="50%">Control for thread debugging library.</td></tr>
<tr><td width="50%">See <a href="libthread_005fdb_002eso_002e1-file.html#show-auto_002dload-libthread_002ddb">show auto-load libthread-db</a>.</td><td width="50%">Show setting of thread debugging library.</td></tr>
<tr><td width="50%">See <a href="libthread_005fdb_002eso_002e1-file.html#info-auto_002dload-libthread_002ddb">info auto-load libthread-db</a>.</td><td width="50%">Show state of thread debugging library.</td></tr>
<tr><td width="50%">See <a href="Auto_002dloading-safe-path.html#set-auto_002dload-safe_002dpath">set auto-load safe-path</a>.</td><td width="50%">Control directories trusted for automatic loading.</td></tr>
<tr><td width="50%">See <a href="Auto_002dloading-safe-path.html#show-auto_002dload-safe_002dpath">show auto-load safe-path</a>.</td><td width="50%">Show directories trusted for automatic loading.</td></tr>
<tr><td width="50%">See <a href="Auto_002dloading-safe-path.html#add_002dauto_002dload_002dsafe_002dpath">add-auto-load-safe-path</a>.</td><td width="50%">Add directory trusted for automatic loading.</td></tr>
</table>

<hr>
<div class="header">
<p>
Next: <a href="Messages_002fWarnings.html#Messages_002fWarnings" accesskey="n" rel="next">Messages/Warnings</a>, Previous: <a href="ABI.html#ABI" accesskey="p" rel="prev">ABI</a>, Up: <a href="Controlling-GDB.html#Controlling-GDB" accesskey="u" rel="up">Controlling GDB</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html#Concept-Index" title="Index" rel="index">Index</a>]</p>
</div>



</body>
</html>
